namespace MoskieBlog.Data.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class AddUsersModel : DbMigration
    {
        public override void Up()
        {
            //CreateTable(
            //    "Users",
            //    c => new
            //        {
            //            UserId = c.Guid(nullable: false),
            //            UserName = c.String(),
            //        })
            //    .PrimaryKey(t => t.UserId);
            
            CreateTable(
                "Comments",
                c => new
                    {
                        CommentId = c.Int(nullable: false, identity: true),
                        Title = c.String(),
                        Text = c.String(),
                        CreateDate = c.DateTime(nullable: false),
                        Commenter_UserId = c.Guid(),
                        Post_PostId = c.Int(),
                    })
                .PrimaryKey(t => t.CommentId)
                .ForeignKey("Users", t => t.Commenter_UserId)
                .ForeignKey("Posts", t => t.Post_PostId)
                .Index(t => t.Commenter_UserId)
                .Index(t => t.Post_PostId);
            
            AddColumn("Posts", "Poster_UserId", c => c.Guid());
            AddForeignKey("Posts", "Poster_UserId", "Users", "UserId");
            CreateIndex("Posts", "Poster_UserId");
        }
        
        public override void Down()
        {
            DropIndex("Comments", new[] { "Post_PostId" });
            DropIndex("Comments", new[] { "Commenter_UserId" });
            DropIndex("Posts", new[] { "Poster_UserId" });
            DropForeignKey("Comments", "Post_PostId", "Posts");
            DropForeignKey("Comments", "Commenter_UserId", "Users");
            DropForeignKey("Posts", "Poster_UserId", "Users");
            DropColumn("Posts", "Poster_UserId");
            DropTable("Comments");
            DropTable("Users");
        }
    }
}
